package com.zyb.warehouse.controller;

import com.zyb.warehouse.common.Result;
import com.zyb.warehouse.dto.Page;
import com.zyb.warehouse.entity.InStore;
import com.zyb.warehouse.entity.Store;
import com.zyb.warehouse.service.InStoreService;
import com.zyb.warehouse.service.StoreService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * Description:入库单控制层
 */
@RestController
@RequestMapping("/instore")
public class InStoreController {

    @Autowired
    private InStoreService inStoreService;
    @Autowired
    private StoreService storeService;

    /**
     * 查询所有仓库
     *
     * @return
     */
    @GetMapping("/store-list")
    public Result queryAllStore() {
        List<Store> storeList = storeService.queryAllStore();
        return Result.ok(storeList);
    }

    /**
     * 分页查询入库单
     *
     * @param page
     * @param inStore
     * @return
     */
    @GetMapping("/instore-page-list")
    public Result page(Page page, InStore inStore) {
        page = inStoreService.pageInStore(page, inStore);
        return Result.ok(page);
    }

    /**
     * 确认入库
     *
     * @param inStore
     * @return
     */
    @PutMapping("/instore-confirm")
    public Result confirmInStore(@RequestBody InStore inStore) {
        Result result = inStoreService.confirmInStore(inStore);
        return result;
    }
}
